package day01;

/**
 * @author Jetwang
 * @version 1.0
 * @since 2023/3/11 16:58
 * 替换空格
 */
public class Offer05 {
    public String replaceSpace(String s) {
        // return s.replaceAll(" ", "%20");

        StringBuilder builder = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (c == ' ') {
                builder.append("%20");
            } else {
                builder.append(c);
            }
        }
        return builder.toString();
    }
}
